package com.ktg.web.wms;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ktg.ktgcommon.domain.wms.WmItemRecpt;
import com.ktg.ktgcommon.domain.wms.WmProductProduceLine;
import com.ktg.ktgcommon.domain.wms.WmProductSalseLine;
import com.ktg.ktgcommon.result.R;
import com.ktg.ktgcommon.vo.WeekDayDate;
import com.ktg.service.wmProductSalseLineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequestMapping("/api")
public class wmProductSalseLineController {
    @Autowired
    private wmProductSalseLineService wmProductSalseLineService;

    //查询本周显示在eChart上面的产品销售出库数据
    @PostMapping("/ProductSalseLine/checkProduct")
    public R checkProduct(){
        List<WeekDayDate>  list= wmProductSalseLineService.checkProduct();
        return R.OK(list);
    }

    //条件查询
    @RequestMapping("/ProductSalseLine/checkPage")
    public R checkPage(LocalDate startDate, LocalDate endDate, String quantitySalse,
                       @RequestParam(defaultValue = "1") Integer pageNo,
                       @RequestParam(defaultValue = "5") Integer pageSize){
        System.out.println("开始时间"+startDate);
        System.out.println("结束时间"+endDate);
        Page<WmProductProduceLine> page = new Page<>(pageNo, pageSize);
        Page<WmProductProduceLine> wmProductProduceLinePage =
                wmProductSalseLineService.checkPage(page,startDate,endDate,quantitySalse);
        if (wmProductProduceLinePage != null) {
            return R.OK(wmProductProduceLinePage);
        }
        return R.FAIL();
    }
}
